package com.game.league.mine.set;

import android.graphics.Paint;
import android.view.View;

import com.game.base.app.App;
import com.game.base.app.base.BaseActivity;
import com.game.base.glideV4.ImageLoader;
import com.game.base.server.upgrade.UpgradeMgr;
import com.game.base.view.dialog.DialogUtils;
import com.game.league.R;
import com.game.league.databinding.ActivitySetBinding;
import com.game.league.entrance.user.UserMgr;
import com.game.league.service.InterfaceMgr;
import com.game.league.util.SkipUtil;

/**
 * 设置页
 * Created by Su on 2019/5/23.
 */
public class SettingActivity extends BaseActivity<ActivitySetBinding> implements View.OnClickListener {
    @Override
    protected int getLayoutId() {
        return R.layout.activity_set;
    }

    @Override
    protected void initView() {
        binding.setTitle("设置");
        binding.setClick(this);

        ImageLoader.loadRoundCenterCropInResource(this, R.mipmap.ic_launcher, binding.ivApp);
        binding.tvVersion.setText("v" + App.getVersionName());
        binding.btnLogout.getPaint().setFlags(Paint.UNDERLINE_TEXT_FLAG);
    }

    @Override
    protected void initData() {
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.title_left_iv:
                finish();
                break;
            case R.id.item_update:
                UpgradeMgr.checkUpdate(mActivity, true);
                break;
            case R.id.btn_logout:
                DialogUtils.showMessagePositiveDialog(this, "退出！", "确定要退出吗？", (dialog, index) -> {
                    UserMgr.logOut();
                    SkipUtil.showLoginActivity(mActivity);
                });
                break;
            case R.id.item_contact:
                SkipUtil.showQQService(this, InterfaceMgr.getConfig().getKf_qq());
                break;
            case R.id.item_business:
                SkipUtil.showQQService(this, InterfaceMgr.getConfig().getBusiness_qq());
                break;
            case R.id.item_about:
                break;
        }
    }
}
